#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const int N = 2e5 + 10, INF = 0x3f3f3f3f;

int n;
int a[N], f[N][2];
int cnt[N];

void solve()
{
    memset(cnt, 0, sizeof cnt);

    cin >> n;
    for (int i = 1;i <= n;i++) cin >> a[i];

    f[0][0] = f[0][1] = 0;
    int mx = 0;
    for (int i = 1;i <= n;i++) {
        f[i][0] = f[i][1] = 0;
        f[i][0] = max(f[i - 1][0], f[i - 1][1]);

        for (int j = 1;j <= a[i] / j;j++)
            if (a[i] % j == 0) {
                f[i][1] = max(f[i][1], cnt[j] + 1);
                if (j != a[i] / j) f[i][1] = max(f[i][1], cnt[a[i] / j] + 1);
            }

        for (int j = a[i];j <= mx;j = j + a[i])
            f[i][1] = max(f[i][1], cnt[j] + 1);

        mx = max(mx, a[i]);
        cnt[a[i]] = max(cnt[a[i]], f[i][1]);
    }
    cout << max(f[n][0], f[n][1]) << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    int T = 1;
    cin >> T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}